# Contributor: Katie Holly <holly@fuslvz.ws>
# Maintainer: Katie Holly <holly@fuslvz.ws>
pkgname=obfs4proxy
pkgver=0.0.11
pkgrel=1
pkgdesc="pluggable transport proxy for Tor, implementing obfs4"
url="https://gitweb.torproject.org/pluggable-transports/obfs4.git/"
arch="x86_64 x86 armv7"
license="BSD-3-Clause"
makedepends="go glide"
options="!strip chmod-clean"
source="$pkgname-$pkgver.tar.gz::https://github.com/Yawning/obfs4/archive/obfs4proxy-$pkgver.tar.gz
	glide.yaml
	glide.lock
	"
builddir="$srcdir"/obfs4-$pkgname-$pkgver
_godir="$srcdir"/go
_vendordir="$_godir"/src/git.torproject.org/pluggable-transports/obfs4.git

unpack() {
	default_unpack
	mkdir -p "$_godir"/bin "$_vendordir" "$builddir/.glide" "$builddir/.glidetmp"
	rmdir "$_vendordir"
	ln -sf "$builddir" "$_vendordir"
	cp "$srcdir"/glide.yaml "$srcdir"/glide.lock "$_vendordir"
}

build() {
	cd "$_vendordir"
	export GOPATH="$_godir"
	export PATH="$PATH:$GOPATH"
	GLIDE_HOME="$builddir/.glide" GLIDE_TMP="$builddir/.glidetmp" glide install
	go build -v -o ./$pkgname-executable ./$pkgname
}

check() {
	cd "$_vendordir"
	go test -short ./...
}

package() {
	mkdir -p "$pkgdir"/usr/bin
	install -Dm755 $pkgname-executable "$pkgdir"/usr/bin/$pkgname
}

sha512sums="3eb50bc8067802f8260e0926999a659919e55cb34247f443f66a4852c9ceceacae361602a57ad1fd28a84e4ed54f3800c3258e67266eb23d45b1d09e31c5d869  obfs4proxy-0.0.11.tar.gz
5531b275dc7954b46382f3e01a5d014cc9e06df001c08d80861c6a65e3110d1152219c76231f4ab0f81d95cff3bebcf4b6c687fd65ec8b0980364a716b9a08c2  glide.yaml
e1a8de9a26d3ae49cf7feb53d16b75c19827a4a04e84a0f44412da25f49152205da17c5be832bd94c0688d7e078679350bd8c0ff9c9fbe3eb9cefed42bedfe2f  glide.lock"
